<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        header{
            width: 100%;
            height: 937px;
            background: rgba(0, 0, 0, .4);
            position: fixed;
            top: 0;
            left: 0;
            display: none;
        }
        nav{
            width: 300px;
            height: 200px;
            background: white;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
        }
    </style>
</head>
<body>
    <button>弹出层</button>
    <header>
        <nav>
            <p>X</p>
        </nav>
    </header>
</body>
</html>
<script>
    let btn =document.querySelector("button")
    let hea=document.querySelector("header")
    let p=document.querySelector("p")
    btn.onclick=function(){
        hea.style.display="block"
    }
    p.onclick=function(){
        hea.style.display='none'
    }
</script>